package com.deep.test

import org.apache.spark.mllib.linalg.Vectors
import org.apache.spark.mllib.stat.{MultivariateStatisticalSummary, Statistics}
import org.apache.spark.{SparkConf, SparkContext}
import org.apache.spark.SparkContext
import org.apache.spark.mllib.linalg._
import org.apache.spark.mllib.stat.Statistics

/**
 * @author sw
 * @create 2023-06-02 14:03
 */
object Test07 {
  def main(args: Array[String]): Unit = {
    val conf = new SparkConf().setMaster("local").setAppName("ALS")
    val sc = new SparkContext(conf)
    sc.setLogLevel("WARN")

    val seriesX = sc.textFile("data/iris.data").map(_.split(",")).map(p => p(0).toDouble)
    val seriesY = sc.textFile("data/iris.data").map(_.split(",")).map(p => p(1).toDouble)
    val correlation: Double = Statistics.corr(seriesX, seriesY, "pearson")
//    print(correlation)
    val data = sc.textFile("data/iris.data").map(_.split(",")).map(p => Vectors.dense(p(0).toDouble, p(1).toDouble))
    val correlMatrix1: Matrix = Statistics.corr(data, "pearson")
    print(correlMatrix1)
  }
}
